<?php
require_once ('../common/mysql/mysqlidb.php');
require_once('../common/mysql/mysql.config.php');
require_once('../common/mysql/tables.config.php');

$mysqlidb_debug = 1;

$db = new \MysqliDb(MYSQL_HOSTADDR, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DB_CALENDAR, MYSQL_PORT, CALENDAR_TABLE_PREFIX);
$openid = @$_REQUEST['openid'];
$year = @$_REQUEST['year'];
$month = @$_REQUEST['month'];
$day = @$_REQUEST['day'];
$lunar_year = @$_REQUEST['lunar_year'];
$lunar_month = @$_REQUEST['lunar_month'];
$lunar_day = @$_REQUEST['lunar_day'];

/*
$openid="o5uf7vhwgo5BA7poRU8NlE57oXD4";
$year = 2016;
$month = 3;
$day = 1;
*/

// 取公历周年纪念日
$db->where('account', $openid) -> where('recycle', 'year') -> where('date_format', '0');
$db->where('remind_month', $month) -> where('remind_day', $day);

// 查 remind_info表格就可以，remind_event表格不用查，用来发信息就可以
$fetv = $db->get(TABLE_CLD_REMIND_INFO);


// 取公历月度纪念日
$db->where('account', $openid) -> where('recycle', 'month') -> where('date_format', '0');
$db->where('remind_day', $day);
$fetv += $db->get(TABLE_CLD_REMIND_INFO);

// 取公历一次纪念日
$db->where('account', $openid) -> where('recycle', 'once') -> where('date_format', '0');
$db->where('remind_year', $year) -> where('remind_month', $month) -> where('remind_day', $day);
$fetv += $db->get(TABLE_CLD_REMIND_INFO);



// 取农历周年纪念日
$db->where('account', $openid) -> where('recycle', 'year') -> where('date_format', '1');
$db->where('remind_month', $lunar_month) -> where('remind_day', $lunar_day);
$fetv += $db->get(TABLE_CLD_REMIND_INFO);

// 取农历月度纪念日
$db->where('account', $openid) -> where('recycle', 'month') -> where('date_format', '1');
$db->where('remind_day', $lunar_day);
$fetv += $db->get(TABLE_CLD_REMIND_INFO);

// 取农历一次纪念日
$db->where('account', $openid) -> where('recycle', 'once') -> where('date_format', '1');
$db->where('remind_year', $lunar_year) -> where('remind_month', $lunar_month) -> where('remind_day', $lunar_day);
$fetv += $db->get(TABLE_CLD_REMIND_INFO);


echo json_encode($fetv);


?>